<?php
/**
 * Cache machnic
 * @author nam nguyen <nam.ngvan@gmail.com>
 * @version 1.0
 * @since apr 22, 2013
 */
class Nuo_Log
{
	
	/**
	 * Store cache engine
	 * @static
	 * @access  private
	 * @var     array
	 */
	static private $_logs =  array();

	/**
	 * no instance
	 */
	private function __construct()
	{
		// no code here
	}

	/**
	 * Get logger object
	 * @static
	 * @access  public
	 * @param   string  $name
	 * @param   array   $config
	 * @return  Nuo_Log_Abstract
	 */
	static public function instance($name = NULL, $config = NULL)
	{
		if (NULL == $name)
		{
			$name = 'default';
		}

		if (!isset(self::$_logs[$name]))
		{
			/**
			 * Load config
			 */
			if (!$config)
			{
				$config = Nuo::readConfigFile('log');

				$config = $config[$name];
			}

			$file = 'nuo/classes/log/' . $config['adapter'] . '.class.php';

			require_once $file;

			$class = 'Nuo_Log_' . ucfirst($config['adapter']);

			self::$_logs[$name] = $log = new $class($config['options']);
		}
		return self::$_logs[$name];
	}


}
